const express=require('express');
const cookieParser=require('cookie-parser');
const server=express();
//增加一个随机秘钥
server.use(cookieParser('asdfd45556'))

server.use('/test', function (req, res){
    if (req.url === '/favicon.ico') {
        return
    }
    req.secret='asdfd45556';
    res.cookie('user', 'blue',{
        signed:true
    });
    res.cookie('user1', 'blue1'); 
    console.log(req.cookies); //无签名cookie
    console.log(req.signedCookies); //签名cookie
    console.log(req.headers.cookie) //浏览器发过来的cookie: user1=blue1; user=s%3Ablue.3byMSHd31XkJ0JszpW7IXndQaUh6XFLxks%2B6%2FzWRdXg
    res.send('ok'); //签名cookie
});

server.listen(8080);